package com.xinqing.test.LetCode;

import java.util.HashMap;

/**
 * @Author:CHQ
 * @Date:2021/7/21 10:02
 * @Description
 */
public class TwoSum {
    public static void main(String args[]) {

        int[] nums={3,5,6,7};
        int[] res=test(nums,8);
        for(int x:res){
            System.out.print(x+" ");
        }

    }
    public static int[] test(int[] nums,int target){
        HashMap<Integer,Integer> map=new HashMap<>();
        for(int i=0;i<nums.length;i++){
             if(map.containsKey(target-nums[i])){
                 return new int[]{map.get(target-nums[i]),i};
             }
             map.put(nums[i],i);
        }
        return null;
    }
}
